#include <iostream>
#include <string>
#include <stack>
using namespace std;

struct Node {
	string val;
	Node* left = nullptr;
	Node* right = nullptr;
};
string sp;
Node* H = nullptr;
void getTree(Node*& h)
{
	string cur;
	cin >> cur;
	if (cur == sp) return;
	h = new Node;
	h->val = cur;
	getTree(h->left);
	getTree(h->right);
}
void p(Node* h, int level)
{
	if (!h) return;
	p(h->right, level + 1);
	cout << string(level * 2, ' ') << h->val << " \n";
	p(h->left, level + 1);
}
int main()
{
	cin >> sp;
	getTree(H);
	p(H, 0);
	return 0;
}